//myHome.html和hisHome.html 这2个页面共同使用的js文件
/**
 * 设置他的（用户）信息
 * @param hisInfo 用户对象
 */
function setInfo(hisInfo) {
    let h = hisInfo;
    if (isNull(h)){
        alert('您要查看的用户不存在或被冻结');
        return;
    }
    $('title,header h3').text(h.nickName + '的主页');
    $('.user-nick').text(h.nickName);
    for (let i in h){
        let firstWord = i.substring(0,1), afterWord = i.substring(1,i.length);
        let v = isNull(h[i]) ? '' : h[i];
        $('#see' + firstWord.toUpperCase() + afterWord).text(v);
    }
    if (!isNull(h.birthday)) {
        $('#seeBirthday').text(h.birthday + '**年');
    }
    let s = h.sex;
    if (!isNull(h.sex)) {
        if (s == '0'){
            s = '男'
        } else if (s == '1'){
            s = '女'
        }else {
            s = '未知';
        }
        $('#seeSex').text(s);
    }
    setMyHeaderImg(h.headerImgPath);
}
/**
 * 获取吐槽html
 * @returns {string} 吐槽html
 */
function getVentHtml(n,v,flag) {
    let imgUrl = '../staticFile/images/common/', delStr = '', id = v.id,
        eyeStr = v.status == 0 ? '所有人可见' : '仅自己可见';
    //如果是我的主页
    if (flag == 'm'){
        delStr = '<span>' +
            '<img width="22" height="22" title="可见状态" alt="可见状态" src="' + imgUrl + 'eye.png"/>' + eyeStr +
        '</span>' +
        '<span delId="' + id + '" class="del-vent">' +
            '<img width="22" height="22" title="删除" alt="删除" src="' + imgUrl + 'delete.png"/>删除' +
        '</span>';
    }
    return '<div class="vent-obj">' +
        '<a target="_blank" href="ventObj.html?' + id + '"><span class="num">' + n + '</span>' +
        '<strong>' + v.title + '</strong>' +
        '<div class="content"><div class="content-text">' + v.shortContent + '</div>' +
        '</a>' +
        '<div>' + delStr +
        '   <span>' +
        '       <img class="like" width="18" height="18" alt="点赞数" src="' + imgUrl + 'like.png"/>' + v.likeTotal +
        '   </span>' +
        '   <span>' +
        '       <img width="16" height="16" src="' + imgUrl + 'reply.png"/>' + v.commentTotal +
        '   </span>' +
        '   <span>' +
        '       <img width="16" height="16" src="' + imgUrl + 'date.png"/>' + v.createDate +
        '   </span>' +
        '</div>' +
        '</div>';
}
/**
 * 设置头像
 * @param imgUrl 头像路径
 */
function setMyHeaderImg(imgUrl) {
    if (isNull(imgUrl)){
        return;
    }
    let iu = imgUrl.replace('apiImages','');
    if (iu.length < 6){
        return;
    }
    let myHeader = $('#uploadImgForm');
    myHeader.children('img').remove();
    myHeader.prepend('<img width="160" height="160" src="/apiImages/' + imgUrl + '">');
    $('.header,.body').hide();
}